#!/usr/bin/perl -w # for syntax highlighting

use gri_secmgr qw(get_cookie_value got_cookie);
use gri_database;
use Data::Dumper;
use MIME::Base64;

# 
# Show all available sections that can be deleted or modified.
# We use the action to set the appropriate link...
#

use Data::Dumper;

sub mm_section_modify_chooser($) {
my $action=shift;

	my $action2=lc(hex_to_string($action));

	my $db_dir=$::GRI_FRONTEND->get_global_directory("database");
	my $docrepos=$::GRI_FRONTEND->get_global_directory("docrepos");
	my $DB=new gri_database("$db_dir/gri.db");

	# Get list of groups that the user belongs too...
	my ($a,$b)=$DB->list_sections();
	# @$b is a list of sections ....

	my $s="";
	my $row=0;
	for my $csec (@$b) {
		my ($c,$d)=$DB->get_section(section=>$csec);
		my $class="gri_odd";
		$class="gri_even" if $row%2==0;
		$row++;
		if($c==1) {
			my ($c1,$c2,$c3,$c4)=$DB->get_section_stats(section=>$csec,docrepos=>$docrepos);
			next if $c1 != 1;
			# Have all necessary stuff to generate the row information now...
			$s.="<tr class=gri_row id=$class>\n";
			$s.="<td class=gri_cell>";
			my $section2=string_to_hex($d->{name});
			my $str=link_to_str("stdlink",$d->{title},"form_docrepos_${action2}_do","action=$action,section=$section2");
			$s.="$str</td>";
			my $count=0;
			if(defined($d->{reader_groups})) {
				my @F=split(/,/,$d->{reader_groups});
				$count=@F;
			}
			$s.="<td class=gri_cell-right>$count</td>";
			$count=0;
			if(defined($d->{publisher_groups})) {
				my @F=split(/,/,$d->{publisher_groups});
				$count=@F;
			}
			$s.="<td class=gri_cell-right>$count</td>";
			$s.="<td class=gri_cell-right>$c2</td>";
			$s.="</tr>\n";
		}
	}
	return $s;
}

# vim: ts=4:sw=4
